using System;
using Bases;
using Modules.Game.Roles;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace Modules.Game.Skills
{
    public struct SkillDescData
    {
        public Vector3 Pos;
        public int Order;
    }

    public class SkillDescItem : MonoBehaviourSimplify, IPointerEnterHandler, IPointerMoveHandler, IPointerExitHandler
    {
        public Text descText;

        public bool isSelect;

        public void OnPointerEnter(PointerEventData eventData)
        {
            isSelect = true;
        }

        public void OnPointerExit(PointerEventData eventData)
        {
            Destroy(gameObject);
        }

        public void OnPointerMove(PointerEventData eventData)
        {
            isSelect = true;
        }

        protected override void OnBeforeDestroy()
        {
        }

        public void UpdateDescData(SkillDescData data)
        {
            isSelect = false;
            GetComponent<RectTransform>().position = data.Pos;

            var skillData = HeroModel.Instance.GetSkillData(data.Order);
            descText.text = skillData.Name + "\n" + "Cd: " + skillData.Attr.Cd + "s" + "\n消耗: " + skillData.Attr.Mp +
                            "mp" + "\n伤害: " + Math.Round(skillData.Attr.Atk);
        }
    }
}